<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div class="list">
    <li>01</li>
    <li>02</li>
    <li>03</li>
    <li>04</li>
    <li>05</li>
    <li>06</li>
    <li>07</li>
    <li>08</li>
    <li>09</li>
    <li>10</li>
  </div>
</body>
<script>
  // function fn(a, b) {
  //   console.log(this);
  //   console.log(a, b);
  // }
  // fn.call(document, 10, 20);

  // function fn(a, b) {
  //   console.log(this);
  //   console.log(a, b);
  // }
  // fn.apply(document, [100, 200]);

  // function fn(a, b) {
  //   console.log(this);
  //   console.log(a, b);
  // }
  // // fn.bind(document.body);

  // // var newFn = fn.bind(document.body, 10, 20);
  // // console.log(newFn);
  // // console.log(newFn === fn); //=>false
  // var newFn = fn.bind(document.body);
  // newFn(1000, 2000);
  console.log("----------------------------------------------------------------");

  // var liList = document.querySelectorAll(".list li");

  // console.log(liList);

  // 伪数组 转 真数组
  // var arr = Array.prototype.slice.call(liList);
  // console.log(arr);

  // var brr = Array.prototype.slice.apply(liList);
  // console.log(brr);

  //模拟封装
  // Array.prototype.mySlice = function (startIndex = 0, endIndex = this.length) {
  //   var list = [];
  //   for (var i = startIndex; i < endIndex; i++) {
  //     var item = this[i]
  //     list.push(item);
  //   }
  //   return list;
  // }

  // var arr = [2, 8, 4, 6, 5, 7, 9, 3, 1];
  // var brr = arr.mySlice(2, 5);
  // console.log(brr);


  // var min = Math.min(2, 8, 4, 6, 5, 7, 9, 3, 1);
  // console.log(min); // =>1
  // var arr = [2, 8, 4, 6, 5, 7, 9, 3, 1];
  // var brr = Math.min(...arr);
  // console.log(brr);  // =>1

  // var min = Math.min.apply(null, arr);
  // console.log(min);
  console.log("----------------------------------------------------------------");

  function Cat(name, color) {
    this.name = name;
    this.color = color;
  }
  Cat.prototype.species = "cat";
  Cat.prototype.call = function () {
    console.log("喵喵");
  }
  Cat.prototype.skill = function () {
    console.log("捉冲波");
  }

  // 此方法虽然存在原型对象中, 但是调用时 是由实例化对象访问的 Tom.say() =>this指向调用此方法的实例化对象
  Cat.prototype.say = function () {
    console.log(this.name, this.color);
  }

  Object.prototype.hello = "你好";

  // 判断一个数据是否是纯对象?({a:1,b:2})
  var Tom = new Cat("Tom", "black");
  console.log(Tom);

  var obj = new Object({ a: 1, b: 2 });

  var arr = new Array(1, 2, 3, 4);
  var date = new Date();
  var reg = new RegExp();

  console.log(Object.prototype.toString.call(Tom));
  console.log(Object.prototype.toString.call(obj));
  console.log(Object.prototype.toString.call(arr));
  console.log(Object.prototype.toString.call(date));
  console.log(Object.prototype.toString.call(reg));

  console.log(Object.prototype.toString.call(Tom) == "[object object]");  //=>false
</script>

</html>